package com.thientan.export;

import net.sf.jasperreports.engine.JasperReport;


/**
 * <p>
 * <code>CustomReportCommand</code> is used to custom report after compile to an *.jasper file. Using template
 * file(*.jrxml) in report should create this command to maintain the layout after compiling because all elements in
 * report page header, page footer, title, summary is not auto resizing. Therefore, <code>CustomReportCommand</code>
 * will be executed before filling data into report to resize it manually.
 * </p>
 * 
 */
public abstract class AbstractCustomReportCommand extends VoidCommand {

    /**
     * {@inheritDoc}
     */
    @Override
    protected void doExecute(Object... args) {
        doCustomReport((JasperReport) args[0], (Integer) args[1]);
    }

    /**
     * Custom report elements width depend on newWidth parameter. If not, your report may have a corrupt GUI.
     * 
     * @param report
     *            JasperReport object before filling data.
     * @param newWidth
     *            new report width.
     * @param additionArgs
     *            Addition arguments (optional for extending in the future not used at current version)
     */
    protected abstract void doCustomReport(JasperReport report, int newWidth, Object... additionArgs);
}
